new Vue({
    el: "#wap_education",
    data() {
        return {
            services: services,
            education:'',
            school:'',
            enterTime:'',
            leaveTime:'',
            major:'',
            currInfo:'',
            currEducation:'',
            currEducationId:'',
            resumeId:'',
            teachId:''
        }
    },
    created () {
        this.education = this.init("get","/user/prop/educationLevel/list?page=0&limit=10&name=");
        var storage=window.localStorage;
        this.currInfo = JSON.parse(storage.education);
        this.school = this.currInfo.school;
        this.enterTime = this.currInfo.admissionTime;
        this.leaveTime = this.currInfo.graduationTime;
        this.major = this.currInfo.profession;
        this.currEducation = this.currInfo.educationLevelName;
        this.currEducationId = this.currInfo.educationLevel;
        this.resumeId = this.currInfo.resumeId;
        this.teachId = this.currInfo.id;
    },
    methods:{
        init:function (_type,_url) {
            var that=this;
            var obj = "";
            $.ajax({
                type: _type,
                async:false,
                url: that.services+_url,
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true,
                success: function (res) {
                    obj = (JSON.parse(res)).data;
                }
            });
            return obj;
        },
        alterEducation:function () {

            this.currEducationId = $("#eduList").val();
            this.enterTime = $('input[name="enterTime"]').val();
            this.leaveTime = $('input[name="leaveTime"]').val();

            if(this.school==''||this.school==null){
                layerMsg("学校名字不为空");
                return
            }
            if(this.enterTime == ''||this.enterTime==null){
                layerMsg('入学时间不为空');
                return
            }
            if(this.leaveTime == ''||this.leaveTime==null){
                layerMsg('毕业时间不为空');
                return
            }
            if(this.major == ''||this.major==null){
                layerMsg('专业不为空');
                return
            }

            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceEducation"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.teachId
                    ,"resumeId": that.resumeId
                    ,"school":that.school
                    ,"educationLevel":that.currEducationId
                    ,"profession":that.major
                    ,"admissionTime":that.enterTime
                    ,"graduationTime":that.leaveTime
                })
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            window.location.href="my-resume.html" ;
                        },500);
                    }
                }
            });
        }
    }
});